package com.xbao.dao;

import com.xbao.model.Lession;
import com.xbao.model.req.LessionReq;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by qingshengzheng on 18/8/27.
 */
@Mapper
public interface LessionMapper {

    @Insert("insert into lession(eid,rid,sid,lessdate,time,status) value(#{eid},#{rid},#{sid},#{lessdate},#{time},#{status})")
    public void addLession(LessionReq lessionReq);
    @Delete("delete * from lession where id=#{id}")
    public void deleteLession(Long id);
@Select("select * from lession where id=#{id}")
    public void detailLession(Long id);
@Select("select * from lession" +
        "<where>" +
        "<if eid!=null && eid!=''>eid=#{eid}</if>" +
        "<if test=\"rid!=null and rid !=''\">rid=#{rid},</if>" +
        "<if test=\"sid!=null and sid !=''\">sid=#{sid},</if>" +
        "<if test=\"lessdate!=null and lessdate !=''\">lessdate=#{lessdate},</if>" +
        "<if test=\"time!=null and time !=''\">time=#{time},</if>" +
        "<if test=\"status!=null and status !=''\">status=#{status},</if>" +
        "</where>")
    public List<Lession> queryLessions(LessionReq lessionReq);

}
